package youleche.com.common.asynchronous;

import youleche.com.common.email.MailFactory;

import com.googlecode.asyn4j.core.handler.CacheAsynWorkHandler;
import com.googlecode.asyn4j.core.handler.DefaultErrorAsynWorkHandler;
import com.googlecode.asyn4j.core.handler.FileAsynServiceHandler;
import com.googlecode.asyn4j.service.AsynService;
import com.googlecode.asyn4j.service.AsynServiceImpl;

public class Test {
	public static void main(String[] args) {
        // 初始化异步工作服务
        AsynService anycService = AsynServiceImpl.getService(300, 3000L, 100, 100,1000);
        //异步工作缓冲处理器
        anycService.setWorkQueueFullHandler(new CacheAsynWorkHandler(100));
        //服务启动和关闭处理器
        anycService.setServiceHandler(new FileAsynServiceHandler());
        //异步工作执行异常处理器
        anycService.setErrorAsynWorkHandler(new DefaultErrorAsynWorkHandler());
        // 启动服务
        anycService.init();
        anycService.addWork(MailFactory.class, "sendMail", new Object[] { " "}, new EmailCallBack());  
	}
}
